<?php

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
 */

namespace app\index\controller;
use think\Controller;
use think\Request;
use app\index\model\User;
/**
 * 用户注册
 *
 * @author Administrator
 */
class Register extends Controller {
    //put your code here
    public function index(){
//        return "register index";
        return view("/register/register");
    }
    
    //用户注册 保存用户数据
    public function insert(Request $request){
        //第一步：接收前端传递的参数
        $param=$request->param();
        echo "<br>";
        var_dump($param);
        $data['user_name']=$param['user'];
        $data['password']=sha1($param['pwd']);//sha1加密
        $data['email']=$param['email'];
        echo "<br>11111111111<br>";
        var_dump($data);      
//        print_r("<br>");
        echo "<br>";

        //第二步：操作数据表并返回结果[使用数据表对于得模型类  cz_user 对于的User模型类]
        $result=User::create($data);
        var_dump($result);
        echo "<br>";
        //第三步：处理返回结果
        if($result){
            $this->success("恭喜你注册成功！", "/index/login/index");
        }else{
            $this->error("注册失败，请继续！", "/index/register/index");
        }
//        return "register insert";
    }

}
